// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

using System.Threading;
using System.Threading.Tasks;

namespace SnapObjects.Data
{
    internal interface IModelLoader
    {
        ISqlQueryBuilder GetQueryBuilder<TModel>(string selectName = null);

        ILoadable<TModel> Load<TModel>(params object[] parameters);

        Task<ILoadable<TModel>> LoadAsync<TModel>(object[] parameters, CancellationToken cancellationToken);

        ILoadable<TModel> LoadByPage<TModel>(int currentIndex, int pageSize, params object[] parameters);

        Task<ILoadable<TModel>> LoadByPageAsync<TModel>(
            int currentIndex, int pageSize, object[] parameters, CancellationToken cancellationToken);

        ILoadable<TModel> LoadAll<TModel>();

        Task<ILoadable<TModel>> LoadAllAsync<TModel>(CancellationToken cancellationToken);

        ILoadable<TModel> LoadAllByPage<TModel>(int currentIndex, int pageSize);

        Task<ILoadable<TModel>> LoadAllByPageAsync<TModel>(
            int currentIndex, int pageSize, CancellationToken cancellationToken);

        ILoadable<TModel> LoadByKey<TModel>(params object[] parameters);

        Task<ILoadable<TModel>> LoadByKeyAsync<TModel>(object[] parameters, CancellationToken cancellationToken);

        IEmbeddedLoadable<TModel> LoadEmbedded<TModel>(TModel model, params object[] parameters);

        bool Exists<TModel>(params object[] parameters);

        bool KeyExists<TModel>(params object[] parameters);

        int Count<TModel>(params object[] parameters);

        int DistinctCount<TModel>(string expression, params object[] parameters);

        object Max<TModel>(string expression, params object[] parameters);

        object Min<TModel>(string expression, params object[] parameters);

        object Avg<TModel>(string expression, params object[] parameters);

        object Sum<TModel>(string expression, params object[] parameters);

        object FetchOne<TModel>(string expression, params object[] parameters);

        Task<TValue> FetchOneAsync<TModel, TValue>(
            string expression, object[] parameters, CancellationToken cancellationToken);

        object FetchOneByKey<TModel>(string expression, params object[] parameters);

        Task<TValue> FetchOneByKeyAsync<TModel, TValue>(
            string expression, object[] parameters, CancellationToken cancellationToken);
    }
}
